package com.mvp.mvpdemo.mvp.model

import android.content.Context
import androidx.lifecycle.LiveData
import com.mvp.mvpdemo.Const
import com.mvp.mvpdemo.base.BaseModel
import com.mvp.mvpdemo.bean.BAnnerBean
import com.mvp.mvpdemo.bean.LoginBean
import com.mvp.mvpdemo.bean.WXBean
import com.mvp.mvpdemo.mvp.contract.HomeContract
import com.retrofit.call_adapter.livedata_call_adapter.ApiResponse
import retrofit2.Call

class HomeModel(val context: Context) : BaseModel(), HomeContract.Model {

    override fun login(phone: String, pwd: String): Call<LoginBean> {
//       apiService.login2(phone, pwd)
//       apiService.login3(Const.BASE_URL+"user/login",phone, pwd)
        return apiService.login4(phone, pwd)

    }

    override fun login2(phone: String, pwd: String): Call<LoginBean> {
        return apiService.login2(phone, pwd)
    }

    /**
     * 使用livadata
     */
    override fun getBanner(): LiveData<ApiResponse<BAnnerBean>> {
        return apiService(context,Const.BASE_URL,null,null).bannerList()
    }

    override fun getWX(): LiveData<ApiResponse<WXBean>> {
        return apiService(context,Const.BASE_URL,null,null).wxList()
    }

}
